﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using QuanLyDuocPham.Controllers.QuanLyHeThong.DanhMuc;
namespace QuanLyDuocPham.View.QuanLyHeThong.DanhMuc
{
    /// <summary>
    /// Interaction logic for KHACHHANG_Add_View.xaml
    /// </summary>
    public partial class KHACHHANG_Add_View : Window
    {
        public KHACHHANG_Add_View()
        {
            InitializeComponent();
        }
        string ma_kh;
        public string _ma_kh
        {
            set
            {
                ma_kh = value;
            }
        }
        public delegate void added();
        public added done;
        KHACHHANG_Control khctrl = new KHACHHANG_Control();
        NHOM_KH_Control nhkhctrl = new NHOM_KH_Control();
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            khctrl.addData(ma_kh,cmbNhomKH, txtTen_KH, chbThuong_Xuyen, txtDia_Chi, txtDien_Thoai, txtDi_Dong, txtEmail, txtWebsite, txtFax, txtMST, txtNguoiDD, txtTen_TK, txtSo_TK, txtTen_NH, txtDiaChi_NH, txtGhi_Chu);
            txtTen_KH.Clear();
            txtWebsite.Clear();
            chbThuong_Xuyen.IsChecked = false;
            txtDia_Chi.Clear();
            txtDien_Thoai.Clear();
            txtEmail.Clear();
            txtDien_Thoai.Clear();
            txtFax.Clear();
            txtMST.Clear();
            txtNguoiDD.Clear();
            txtTen_TK.Clear();
            txtSo_TK.Clear();
            txtTen_NH.Clear();
            txtDiaChi_NH.Clear();
            txtGhi_Chu.Document.Blocks.Clear();
            cmbNhomKH.SelectedItem = null;
            ma_kh=khctrl.loadID_moi();

            if (done != null)
            {
                done();
            }
        }

        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            this.Close();

        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            nhkhctrl.loadComboBox(cmbNhomKH);
            ma_kh = khctrl.loadID_moi();

        }
    }
}
